<<<<<<< HEAD
package com.wwx.web;

import java.util.List;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;

import org.apache.struts2.ServletActionContext;

import com.opensymphony.xwork2.ActionContext;
import com.opensymphony.xwork2.ActionSupport;
import com.wwx.entity.CartoonDO;
import com.wwx.service.RankingService;
import com.wwx.service.impl.RankingServiceImp;


/**
 * 排行榜的Action
 * @author Wyndem
 *
 */
public class RankingAction extends ActionSupport {

	//依赖RankingService接口
	private RankingService ranking=null;
	//排行榜显示的个数
	private final int  TOPNUMBER=10;

	private String type;
	
	
	public String getType() {
		return type;
	}
	public void setType(String type) {
		this.type = type;
	}
	public RankingAction(){
		ranking=new RankingServiceImp();
	}
	
	/**
	 * 月票总排行榜
	 * @return
	 */
	public String ticket() {
		try {
			List<CartoonDO> list = ranking.ticketTop(TOPNUMBER);
			Map<String, Object> map = ActionContext.getContext().getContextMap();
			map.put("ticket", list);
			return SUCCESS;
		} catch (Exception e) {
			return ERROR;
		}
	}
	
	/**
	 * 点击排行榜
	 * @return
	 */
	public String click() {
		try {
			List<CartoonDO> list = ranking.clickTop(TOPNUMBER);
			Map<String, Object> map = ActionContext.getContext().getContextMap();
			map.put("click", list);
			return SUCCESS;
		} catch (Exception e) {
			return ERROR;
		}
	}
	
	/**
	 * 收藏
	 * @return
	 */
	public String collection() {
		try {
			List<CartoonDO> list = ranking.collectionTop(TOPNUMBER);
			Map<String, Object> map = ActionContext.getContext().getContextMap();
			map.put("collection", list);
			return SUCCESS;
		} catch (Exception e) {
			return ERROR;
		}
	}
	
	
	// 重载不同类型的排行榜
	
	/**
	 * 月票总排行榜
	 * @return
	 */
	public String ticketType() {
		try {
			List<CartoonDO> list = ranking.ticketTop(type,TOPNUMBER);
			Map<String, Object> map = ActionContext.getContext().getContextMap();
			map.put("ticketType", list);
			return SUCCESS;
		} catch (Exception e) {
			return ERROR;
		}
	}
	
	/**
	 * 点击排行榜
	 * @return
	 */
	public String clickType() {
		try {
			List<CartoonDO> list = ranking.clickTop(type,TOPNUMBER);
			Map<String, Object> map = ActionContext.getContext().getContextMap();
			map.put("clickType", list);
			return SUCCESS;
		} catch (Exception e) {
			return ERROR;
		}
	}
	
	/**
	 * 收藏
	 * @return
	 */
	public String collectionType() {
		try {
			List<CartoonDO> list = ranking.collectionTop(type,TOPNUMBER);
			Map<String, Object> map = ActionContext.getContext().getContextMap();
			map.put("collectionType", list);
			return SUCCESS;
		} catch (Exception e) {
			return ERROR;
		}
	}
	
	@Override
	public String execute() throws Exception {
		try {
			ticket();
			click();
			collection();
			return SUCCESS;
		} catch (Exception e) {
			return ERROR;
		}
	}
	
	
}
=======
package com.wwx.web;

import java.util.List;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;

import org.apache.struts2.ServletActionContext;

import com.opensymphony.xwork2.ActionContext;
import com.opensymphony.xwork2.ActionSupport;
import com.wwx.entity.CartoonDO;
import com.wwx.service.RankingService;
import com.wwx.service.impl.RankingServiceImp;


/**
 * 排行榜的Action
 * @author Wyndem
 *
 */
public class RankingAction extends ActionSupport {

	//依赖RankingService接口
	private RankingService ranking=null;
	//排行榜显示的个数
	private final int  TOPNUMBER=10;

	private String type;
	
	
	public String getType() {
		return type;
	}
	public void setType(String type) {
		this.type = type;
	}
	public RankingAction(){
		ranking=new RankingServiceImp();
	}
	
	/**
	 * 月票总排行榜
	 * @return
	 */
	public String ticket() {
		try {
			List<CartoonDO> list = ranking.ticketTop(TOPNUMBER);
			Map<String, Object> map = ActionContext.getContext().getContextMap();
			map.put("ticket", list);
			return SUCCESS;
		} catch (Exception e) {
			return ERROR;
		}
	}
	
	/**
	 * 点击排行榜
	 * @return
	 */
	public String click() {
		try {
			List<CartoonDO> list = ranking.clickTop(TOPNUMBER);
			Map<String, Object> map = ActionContext.getContext().getContextMap();
			map.put("click", list);
			return SUCCESS;
		} catch (Exception e) {
			return ERROR;
		}
	}
	
	/**
	 * 收藏
	 * @return
	 */
	public String collection() {
		try {
			List<CartoonDO> list = ranking.collectionTop(TOPNUMBER);
			Map<String, Object> map = ActionContext.getContext().getContextMap();
			map.put("collection", list);
			return SUCCESS;
		} catch (Exception e) {
			return ERROR;
		}
	}
	
	
	// 重载不同类型的排行榜
	
	/**
	 * 月票总排行榜
	 * @return
	 */
	public String ticketType() {
		try {
			List<CartoonDO> list = ranking.ticketTop(type,TOPNUMBER);
			Map<String, Object> map = ActionContext.getContext().getContextMap();
			map.put("ticketType", list);
			return SUCCESS;
		} catch (Exception e) {
			return ERROR;
		}
	}
	
	/**
	 * 点击排行榜
	 * @return
	 */
	public String clickType() {
		try {
			List<CartoonDO> list = ranking.clickTop(type,TOPNUMBER);
			Map<String, Object> map = ActionContext.getContext().getContextMap();
			map.put("clickType", list);
			return SUCCESS;
		} catch (Exception e) {
			return ERROR;
		}
	}
	
	/**
	 * 收藏
	 * @return
	 */
	public String collectionType() {
		try {
			List<CartoonDO> list = ranking.collectionTop(type,TOPNUMBER);
			Map<String, Object> map = ActionContext.getContext().getContextMap();
			map.put("collectionType", list);
			return SUCCESS;
		} catch (Exception e) {
			return ERROR;
		}
	}
	
	@Override
	public String execute() throws Exception {
		try {
			ticket();
			click();
			collection();
			return SUCCESS;
		} catch (Exception e) {
			return ERROR;
		}
	}
	
	
}
>>>>>>> dev
